<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>身高体重计算</title>
	
    <script>
        function calculateBMI() {
            var weight = parseFloat(document.getElementById('weight').value);
            var height = parseFloat(document.getElementById('height').value);
			
            if (!isNaN(weight) && !isNaN(height)) {
                var bmi = weight / (height * height);
                alert('你的身高体重比为: ' + bmi.toFixed(2));
            } else {
                alert('Please enter valid numbers for weight and height.');
            }
        }
    </script>
</head>
<body>
    <h1>身高体重计算</h1>
    <label for="weight">体重(kg):</label>
    <input type="number" id="weight" step="0.1">
    <label for="height">身高(m):</label>
    <input type="number" id="height" step="0.01">
    <button onclick="calculateBMI()">计算</button>
</body>
</html>
